Skip to content

fix: prevent false success for unsupported system backend - #65

Merged
srpatcha merged 2 commits into
embeddedos-org:masterfrom
muhammadburhandevv-hub:fix/system-backend-false-success
Sep 1, 2026
Merged

fix: prevent false success for unsupported system backend#65
srpatcha merged 2 commits into
embeddedos-org:masterfrom
muhammadburhandevv-hub:fix/system-backend-false-success

Conversation

@muhammadburhandevv-hub

Copy link
Copy Markdown

Summary

Fixes an issue where eBuild could report a successful build even though no
supported build backend ran. A system: section is now kept separate from
backend configuration, and unsupported backends fail with a clear error.

Type of Change

  • feat — New feature
  • fix — Bug fix
  • docs — Documentation only
  • style — Formatting, no code change
  • refactor — Code restructuring without behavior change
  • test — Add or fix tests
  • build — Build system or dependency changes
  • ci — CI/CD pipeline changes
  • perf — Performance improvement

Changes

  • Keep system: settings separate from compilation backend configuration.
  • Preserve explicit backend selection and normal backend auto-detection.
  • Raise BackendError when the external dispatcher cannot handle a backend.
  • Add configuration, dispatcher, and CLI regression tests.
  • Reconcile the fix with the latest upstream dispatcher changes.

Testing

  • Unit tests pass (ctest --test-dir build --output-on-failure)
  • Integration tests pass
  • Manual testing performed
  • New tests added for new functionality

Focused Python regression tests:

47 passed

Additional validation:

  • Python compilation passed.
  • git diff --check passed.
  • Full pytest suite: 198 passed, 11 failed, 1 skipped.

Pre-Submission Checklist

  • Code compiles without warnings (-Wall -Wextra -Werror for C)
  • All existing tests pass
  • New tests added for new functionality
  • Documentation updated if API changed
  • Commit messages follow <type>(<scope>): <description> convention
  • Branch is rebased on latest master

Related Issues

No related issue number.

Screenshots / Logs

============================= 47 passed in 0.33s =============================

Additional Notes

  • This change does not implement a new system compilation backend.
  • The CTest command was not run because this contribution changes the Python
    eBuild implementation and its pytest suite.
  • The full pytest failures are outside this change. Three require cpio, which
    is unavailable in the Windows test environment. The remaining failures come
    from an existing missing NinjaBackend._object_path method.

Signed-off-by: muhammadburhandevv-hub <muhammadburhandevv@gmail.com>
@srpatcha

Copy link
Copy Markdown
Member

Same defect as #66, reached from a different direction — needs a rebase

The problem you are fixing is real and it is the same one #66 addresses: BackendDispatcher accepting a backend it does not implement and letting the caller report "Build completed successfully" when nothing ran.

Both PRs edit ebuild/build/dispatch.py and they conflict with each other. #66 is further along — it also repairs three defects that stop master running at all:

$ ebuild new hi && cd hi && ebuild build
  File ".../ebuild/build/dispatch.py", line 133
    else:
    ^^^^
SyntaxError: invalid syntax

$ pytest
2 errors during collection

So I have approved #66 to land first. Verified locally: this branch on current master is 9 failed / 201 passed, and it conflicts with #66 in dispatch.py.

What is yours alone, and worth keeping

Two things in here are not in #66, and I would not want them lost in the rebase:

Suggested rebase

Once #66 lands, drop your dispatch.py hunks in favour of its version — it raises RuntimeError from configure(), build() and clean() uniformly, and removes "ninja" from the list of backends that need no configure step, which is the specific hole that let configure("ninja") succeed silently. Then keep the core/config.py change and the CLI test on top. That should be a small branch and I will merge it.

One question worth settling while you are in there: #66 standardised on RuntimeError and this PR raises BackendError. A dedicated exception type is arguably better, but the tree currently has two test files that already disagree about which type to expect, so whichever wins should win everywhere rather than adding a third. If you would rather introduce BackendError properly, that is fine by me — just make configure, build and clean all raise it and update both tests/ebuild/test_dispatch.py and tests/unit/test_dispatch.py.

srpatcha
srpatcha previously approved these changes Aug 30, 2026

@srpatcha srpatcha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for the config.py half, which is a real bug nobody else has covered.

The unique and valuable part

System-image settings are not a compilation backend. Keep them separate.

That is exactly right, and I verified the failure. config.py:230 sets

if raw.get("system") and isinstance(raw["system"], dict):
    backend_config.update(raw["system"])
    if backend == "auto":
        backend = "system"

but "system" is not a backend:

ALL_BACKENDS = {"cmake", "make", "meson", "cargo", "kbuild", "ninja"}

So a build.yaml with a perfectly valid system: section selects a backend the
dispatcher has never heard of. Before #66 that fell through silently — the false
success in your title. With #66 merged it now fails, which is better, but with a
message that blames the user's own valid configuration:

$ ebuild build          # build.yaml has a system: section
[error] Unknown build backend 'system'. Supported backends: cargo, cmake,
        kbuild, make, meson.
exit=1

ebuild system exists as a command, so system-image builds are a supported
feature being reported as an unknown backend. Your split — keeping
system_config out of backend selection entirely, with 'system' must be a mapping validation and a None guard — fixes the cause rather than the
symptom. Neither #66 nor any other open PR touches this.

The dispatch.py half overlaps #66

BackendError(RuntimeError) here and UnknownBackendError(ValueError, RuntimeError) in #66 solve the same problem. #66's inherits from both
deliberately, because the two existing test suites disagreed about which
exception to expect:

tests/ebuild expects ValueError("Unknown build backend '<name>'") while
tests/unit expects RuntimeError matching "ninja". Both are legitimate
readings.

BackendError(RuntimeError) alone would fail the tests/ebuild expectation. #66
is also already approved and carries the master syntax repair (#87), so it
lands first either way.

Suggested path

Rebase onto #66 and drop the dispatch.py and tests/ebuild/test_dispatch.py
hunks, keeping config.py, tests/ebuild/test_config_validation.py and
tests/ebuild/test_build_cli.py. This then reviews cleanly on its own merits and
the part that is uniquely yours is not stuck behind a conflict.

Approving now so it is not blocked on me, but it does need that rebase before it
can merge.

@muhammadburhandevv-hub

muhammadburhandevv-hub commented Aug 31, 2026 via email

Copy link
Copy Markdown
Author

srpatcha pushed a commit to muhammadburhandevv-hub/ebuild that referenced this pull request Sep 1, 2026
PackageRecipe.validate() accepts any non-empty version string, but the
registry ordered versions with

    sorted(versions, key=lambda v: [int(x) for x in v.split('.')])

which raises ValueError for anything that is not dotted integers. Real
recipes are full of those: a leading v (littlefs and FreeRTOS both publish
their tags that way -- the recipe example in the book uses `tag: V10.5.1`),
pre-release tags like 3.6.0-rc1, and build metadata like 1.3.1+patch2.

The blast radius is wider than the odd package itself. The key was
duplicated across get(), list_packages() and list_all_versions(), and

  * get(name) with no version scans every version of that package, so one
    such recipe breaks that package entirely;
  * list_packages() scans every package, and PackageResolver builds its
    "package not found in registry. Available: ..." message from it -- so a
    single unusual recipe anywhere in the registry turns an ordinary
    missing-package error into a ValueError traceback.

Replace the three copies with one version_sort_key(). Ordering: a leading
v/V is ignored; all-digit components compare numerically so 1.10.0 still
sorts above 1.9.0; any other component compares as text and ranks below a
numeric one; a -/+ suffix ranks below the same version without one, so
3.6.0-rc1 < 3.6.0. The order is total and never raises, which is the
property that matters here -- one unusual recipe must not decide whether
lookup works for the packages around it.

Deliberately not a full PEP 440 / semver implementation. That would mean a
dependency or a lot more code for a comparison the recipe format does not
specify; this defines the rules it does need and documents them.

Tests: tests/ebuild/test_package_registry.py grows from 1 case to 12,
covering v-prefixes, pre-releases, build metadata, date-stamped and
non-numeric versions, one odd version among good ones, and a totality check
over the key. Nine of the eleven behavioural cases fail against the unfixed
registry.py (checked by running them against it); the other two are the
pre-existing numeric-order test and "2024.06", which parsed as ints before.

Docs: the ordering rules are now in docs/book/book.md section 12.5.

Note on CI: master currently fails for reasons unrelated to this change --
ebuild/build/dispatch.py has a duplicated `else:` from a merge, so the
module does not parse (PRs embeddedos-org#65/embeddedos-org#66 address it), and ninja_backend.py is
missing _object_path. This branch leaves the failure set exactly as it
found it: 26 failed / 162 passed before and after, identical lists.

Verified: pytest tests/ebuild/test_package_registry.py -> 12 passed.
Verified: ruff check --select=E,F,W --ignore=E501 and mypy
--ignore-missing-imports on both changed files -> clean.
@srpatcha
srpatcha merged commit 2d6b18d into embeddedos-org:master Sep 1, 2026
@muhammadburhandevv-hub

muhammadburhandevv-hub commented Sep 4, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants